package esempio.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "SELLER")
public class Seller {
	private long sellerId;
	private String name;
	private String username;
	private String password;
	private Set<Request> requests = new HashSet<Request>(0);
	private Address address;
	
	
	

	public Seller(String name, String username, String password,
			Set<Request> requests, Address address) {
		
		this.name = name;
		this.username = username;
		this.password = password;
		this.requests = requests;
		this.address = address;
	}


	@Id
	@GeneratedValue
	@Column(name="SELLER_ID")
	public long getSellerId() {
		return sellerId;
	}

	public void setSellerId(long sellerId) {
		this.sellerId = sellerId;
	}
	@Column(name="NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column(name="USERNAME")
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	@Column(name="PASSWORD")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	@OneToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "SELLER_REQUEST",joinColumns = {@JoinColumn(name = "SELLER_ID") }, inverseJoinColumns = { @JoinColumn(name = "REQUEST_ID") })
	public Set<Request> getRequests() {
		return requests;
	}

	public void setRequests(Set<Request> requests) {
		this.requests = requests;
	}


	@Embedded
	public Address getAddress() {
		return address;
	}



	public void setAddress(Address address) {
		this.address = address;
	}
	
	

}
